
Page({
  request(config){
    return new Promise((resolve, reject)=>{
      wx.request({
        url:config.url,
        method:config.method,
        data:config.data,
        success:(res)=>{
          resolve(res.data);
        },
        fail:(error)=>{
          reject(error)
        }
      })
    })
  },
 async getBook(){
    wx.showLoading({
      title: '加载中...',
      mask:true
    })
 const data= await this.request({
      url: 'https://hmajax.itheima.net/api/books',
      method: 'GET',
      data: {
        creator: 'zhangsan'
      },
    })
    this.setData({bookList:data.data}),
    wx.hideLoading()
  }
})